package am.fp.events
{                                    
  import flash.events.Event;
  
  public class ScrollPageEvent extends Event
  { 
    // event type
    public static const SCROLL: String = "scrollPage";
  
    // scroll directions
    public static const HOME: String = "home";
    public static const END: String = "end";
    public static const LEFT: String = "left";
    public static const RIGHT: String = "right";
    public static const UP: String = "up";
    public static const DOWN: String = "down";
    public static const PAGE_UP: String = "pageUp";
    public static const PAGE_DOWN: String = "pageDown";
    
    // scroll delta
    private static const SCROLL_DELTA: int = 30;
    private static const PAGE_SCROLL_DELTA: int = 300;
    
    // members and getters
    private var m_direction: String;
    private var m_delta: int;
    private var m_horizontal: Boolean;
    public function get direction() : String  { return m_direction;  }
    public function get delta()     : int     { return m_delta;      }
    public function get horizontal(): Boolean { return m_horizontal; }

    // constructor
    public function ScrollPageEvent(type: String, direction: String)
    {
      m_direction = direction;  
      if (direction == LEFT || direction == RIGHT)
        m_horizontal = true;
      else
        m_horizontal = false;
      if (direction == PAGE_UP)
        m_delta = -PAGE_SCROLL_DELTA;
      else if (direction == PAGE_DOWN)
        m_delta = PAGE_SCROLL_DELTA;
      else if (direction == LEFT || direction == UP)
        m_delta = -SCROLL_DELTA;
      else if (direction == RIGHT || direction == DOWN)
        m_delta = SCROLL_DELTA;
        
      super(type, false, false);
    }
  }
}
